﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataAccess;

namespace QUANLYKHACHSAN_N4
{
    public partial class frmChiTietPhieuChi : Form
    {
        public bool acction = false;
        public frmChiTietPhieuChi()
        {
            InitializeComponent();
            btnCapNhat.Enabled = false;
            txtMaPhieu.Enabled = true;
        }
        public TaiKhoan_Info tk = new TaiKhoan_Info();
        public frmChiTietPhieuChi(PhieuChi_Info pt)
        {
            InitializeComponent();
            BindToForm(pt);
            txtMaPhieu.Enabled = btnThem.Enabled = txtNhanVien.Enabled = false;

        }

        void BindToForm(PhieuChi_Info pt)
        {
            txtMaPhieu.Text = pt.maphieu;
            dtpNgayLap.Value = pt.ngaylap;
            txtNhanVien.Text = pt.hovaten;
            txtNoiDung.Text = pt.noidung;
            txtSoTien.Text = pt.sotien;
            txtBangChu.Text = pt.bangchu;
        }
        private void btnThoat_Click(object sender, EventArgs e)
        {            
            this.Close();
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            if (PhieuChi_Info.Add(txtMaPhieu.Text,
                dtpNgayLap.Value,tk.manv,txtNoiDung.Text,decimal.Parse(txtSoTien.Text),txtBangChu.Text))
            {
                BatLoi.ThongBao("Thêm Phiếu Thu Thành Công");
                acction = true;
                this.Close();
            }
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (PhieuChi_Info.Update(txtMaPhieu.Text,
                dtpNgayLap.Value, txtNoiDung.Text, decimal.Parse(txtSoTien.Text), txtBangChu.Text))
            {
                BatLoi.ThongBao("Cập Nhật Phiếu Thu Thành Công");
                acction = true;
                this.Close();
            }
        }

        private void frmChiTietPhieuChi_Load(object sender, EventArgs e)
        {
            txtNhanVien.Text = tk.hovaten;
        }
    }
}
